<script type="text/javascript">

var str = "aaaaaaasdfasdwerwerasadfsadfaaaaaaaaa";
var result = Group(str);
function Group(str)
{
	var result = new Array();
	for(var j=0;j<str.length;j++){
		if(result.length>0){
			var isFind = false;
			for(var k=0;k<result.length;k++){
			  if(result[k].v == str[j]){
				   result[k]= {v:result[k].v,count:result[k].count+1};
				   isFind=true;
				}
			}
			if(!isFind){
				var obj = new Object();
				obj.v=str[j];
				obj.count=1;
				result.push(obj);
			}
		}else{
		   var obj = new Object();
		   obj.v=str[j];
		   obj.count=1;
		   result.push(obj);
		}
	}
	return result;
}


for(var i=0;i<result.length;i++){
	document.write(result[i].v + "  " + result[i].count +"<br>");
}

</script>